package xyz.lovegu.server.sys.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import xyz.lovegu.server.sys.common.*;
import xyz.lovegu.server.sys.service.LoginfoService;
import xyz.lovegu.server.sys.vos.UserVo;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @author 老顾
 * @title: LoginController
 * @projectName campus-prevention-system
 * @email: 1437594522@qq.com
 * @date 2022/5/5 20:08
 */
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("sys/login")
public class LoginController {

    private final LoginfoService loginfoService;

    @PostMapping("userLogin")
    public ResultMessage<ResultObj> userLogin(@RequestBody UserVo userVo, HttpSession session){
        return ResultUtil.data(loginfoService.userLogin(userVo,session));
    }


    @GetMapping("getCode")
    public void getCode(HttpServletResponse response, HttpSession session) {
        loginfoService.getCode(response,session);
    }
}
